﻿using System;

internal struct Point : IComparable
{
    private Int32 m_x, m_y;

    //构造器负责初始化字段
    public Point(Int32 x, Int32 y)
    {
        m_x = x;
        m_y = y;
    }
//重写SystemValueType继承的ToString方法
    public override string ToString()
    {
        return String.Format("({0},{1})", m_x, m_y); //将point作为字符串输出
       // return base.ToString();
    }
    //实现类型安全的CompareTo方法
    public Int32 CompareTo(Point other)
    {
        return Math.Sign(Math.Sqrt(m_x * m_x + m_y * m_y) - Math.Sqrt(other.m_x * other.m_x + other.m_y * other.m_y));
    }
    
    //实现Icomparable的CompareTo方法
    public Int32 CompareTo(Object o)
    {
        if (GetType() != o.GetType())
        {
            throw new ArgumentException("o is not a Point");
        }
        //调用类型安全的CompareTo方法
        return CompareTo((Point)o);
    }

    public void Change(Int32 x, Int32 y)
    {
        this.m_x = x;
        this.m_y = y;
    }
}